package com.bw.spark02.rdd.action

import org.apache.spark.{SparkConf, SparkContext}


object RDD_20_foreachPartition {
    
    def main(args: Array[String]): Unit = {
    
        // 初始化编程入口
        val sparkConf = new SparkConf()
        sparkConf.setMaster("local")
        sparkConf.setAppName("RDD_Test")
        val sc = new SparkContext(sparkConf)
    
        val names = List("dog", "cat", "gnu", "salmon", "rabbit", "turkey", "wolf", "bear", "bee")
        val rdd1 = sc.parallelize(names, 3)
        
        rdd1.foreachPartition(iter => {
            println("----------------------------")
            for (x <- iter){
                println(x)
            }
        })
    }
}
